package com.ruoyi.framework.config;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.project.system.domain.SysReceive;
import com.ruoyi.project.system.service.ISysReceiveService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @description:
 * @author: gkk
 * @date: Created in 2021/6/15 14:03
 */
@Component
@RabbitListener(queues = "callBackC")
public class ConsumerCallBackC {

    @Autowired
    private ISysReceiveService sysReceiveService;

    @RabbitHandler
    public void process(JSONObject receive) {
        System.out.println(receive.toJSONString());
      /*  if (null != receive && receive.containsKey("coupon_id")) {
            SysReceive sysReceive = new SysReceive();
            sysReceive.setRemark(receive.getString("coupon_id"));
            List<SysReceive> lists = sysReceiveService.selectSysReceiveList(sysReceive);
            if (!lists.isEmpty()) {
                SysReceive sys = lists.get(0);
                sys.setUsed(receive.getString("status"));
                sys.setTimes(new Date());
                sysReceiveService.updateSysReceiveData(sys);
            }
        }*/
    }
}
